package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.service.MemberService;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.*;


@RestController
@RequestMapping("/report")
public class ReportController {

    @Reference
    private MemberService memberService;

    @Reference
    private ReportService reportService;
    @RequestMapping("/getMemberReport")
    public Result getMemberReport(){
        try{
            Map map =  memberService.findMemberCount();
             return new Result(true,null,map);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false,"服务器正忙，请稍后访问");
        }
    }

    @RequestMapping("/getSetmealReport")
    public Result getSetmealReport(){
        Map<String,Object> map=null;
        try{
            map = memberService.getSetmeaReport();
            return  new Result(true,null,map);
        }catch(Exception e){
            e.printStackTrace();
        return  new Result(false,"服务器正忙，请稍后访问");
        }
    }

    @RequestMapping("/getBusinessReportData")
    public Result getBusinessReportData(){

        try{
            Map<String,Object> map = reportService.getBusinessReportData();
            return new Result(true,null,map);
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_DATASROCE_FILED);
        }
    }

}
